package com.lss.music.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;

import com.lss.music.databinding.FragmentDiscoveryBinding;
import com.lss.music.viewmodel.DiscoveryViewModel;

public class DiscoveryFragment extends Fragment {
    private DiscoveryViewModel mViewModel;

    private FragmentDiscoveryBinding binding;
    public static DiscoveryFragment newInstance() {
        return new DiscoveryFragment();
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {

        binding = FragmentDiscoveryBinding.inflate(inflater, container, false);
        return binding.getRoot();
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        // 设置生命周期所有者
        binding.setLifecycleOwner(getViewLifecycleOwner());
        mViewModel = new ViewModelProvider(this).get(DiscoveryViewModel.class);

        // 绑定ViewModel
        binding.setVm(mViewModel);
        // TODO: Use the ViewModel
        setupObservers();
    }

    /**
     * 设置观察者
     */
    private void setupObservers() {

    }



    @Override
    public void onDestroyView() {
        super.onDestroyView();
        binding = null;
    }
}